package com.bird.weichat.server;

import com.alibaba.fastjson.JSONObject;
import com.bird.weichat.conf.WeiChatTemplateProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @author sijunqiang
 * @data 2021/7/19 23:17
 * @description:
 */
@Slf4j
@Service
public class WeiChatTemplateServerImpl implements WeiChatTemplateServer {

    @Autowired
    WeiChatTemplateProperties properties;


    @Override
    public WeiChatTemplateProperties.WeiChatTemplate getWeiChatTemplate() {
        List<WeiChatTemplateProperties.WeiChatTemplate> template = properties.getTemplates();
        Optional<WeiChatTemplateProperties.WeiChatTemplate> optional
                = template.stream().filter(WeiChatTemplateProperties.WeiChatTemplate::isActive).findFirst();
        return optional.isPresent() ? optional.get() : null;
    }

    @Override
    public void templateReported(JSONObject reportInfo) {

    }

    @Override
    public JSONObject templateStatistics(String templateId) {
        return null;
    }
}
